import request from '@/config/axios'

const baseURL = 'train/course/achievement'

//推广员业绩汇总
export type TotalsStatsVO = {
  id: string
  nickName: string
  avatar: string
  mobile: string
  inviteUsers: number
  saleOrders: number
  inviteBonus: number
  saleBonus: string
}

export type TotalsStatsPageParam = PageParam & Partial<Pick<TotalsStatsVO, 'nickName'>>

export type SearchTotalsStats = PageParam & {
  nickname?: string
  mobile?: string
}

/** 分页获取推广员业绩汇总，可根据nickName过滤 */
export const getTotalsStatsList = (data: TotalsStatsPageParam) =>
  request.post<PageResult<TotalsStatsVO[]>>({
    url: `${baseURL}/get-totals-stats`,
    data
  })

// 搜索数据
export const searchTotalsStats = (data: SearchTotalsStats) => {
  request.post<PageResult<TotalsStatsVO[]>>({
    url: `${baseURL}/search-totals-stats`,
    data
  })
}

// 推广员业绩月统计
export type MonthStatsVO = {
  id: string
  nickName: string
  avatar: string
  mobile: string
  ststMonth: string
  inviteUsers: number
  saleOrders: number
  inviteBonus: number
  saleBonus: string
}

export type MonthStatsPageParam = PageParam & Partial<Pick<MonthStatsVO, 'nickName'>>

export type SearchMonthStats = PageParam & {
  nickname?: string
  mobile?: string
  month?: string
}

/** 分页获取推广员业绩月统计，可根据nickName过滤 */
export const getMonthStatsList = (data: MonthStatsPageParam) =>
  request.post<PageResult<MonthStatsVO[]>>({
    url: `${baseURL}/get-month-stats`,
    data
  })

export const searchMonthTotals = (data: SearchMonthStats) => {
  request.post<PageResult<MonthStatsVO[]>>({
    url: `${baseURL}/search-month-stats`,
    data
  })
}

// 平台分销月统计
export type PlatformMonthStatsVO = {
  id: string
  ststMonth: string
  inviteUsers: number
  saleOrders: number
  inviteBonus: number
  saleBonus: string
}

export type PlatformMonthStatsPageParam = PageParam &
  Partial<Pick<PlatformMonthStatsVO, 'saleOrders'>>

export type SearchPlatformMonthStats = PageParam & {
  month?: string
}

export const getPlatformMonthStatsList = (data: PlatformMonthStatsPageParam) => {
  request.post<PageResult<PlatformMonthStatsVO[]>>({
    url: `${baseURL}/get-platform-month-stats`,
    data
  })
}

export const searchPlatformMonthStats = (data: SearchPlatformMonthStats) => {
  request.post<PageResult<PlatformMonthStatsVO[]>>({
    url: `${baseURL}/search-platform-month-stats`,
    data
  })
}

// 报名订单日统计
export type EnrollOrdersDayStatsVO = {
  id: string
  ststDate: string
  spuId: number
  spuName: string
  skuId: number
  skuName: string
  orderNum: number
  orderAmount: number
}

export type EnrollOrdersDayStatsPageParam = PageParam &
  Partial<Pick<EnrollOrdersDayStatsVO, 'orderNum'>>

export type SearchEnrollOrdersDayStats = {
  day?: string
  nickname?: string
  mobile?: string
}

// 获取列表
export const getEnrollOrdersDayStatsList = (data: EnrollOrdersDayStatsPageParam) => {
  request.post<PageResult<EnrollOrdersDayStatsVO[]>>({
    url: `${baseURL}/get-enroll-orders-day-stats`,
    data
  })
}

// 搜索报名订单日统计
export const searchEnrollOrdersDayStats = (data: SearchEnrollOrdersDayStats) => {
  request.post<PageResult<EnrollOrdersDayStatsVO[]>>({
    url: `${baseURL}/search-enroll-orders-day-stats`,
    data
  })
}

// 报名订单月统计
export type EnrollOrdersMonthStatsVO = {
  id: string
  ststDate: string
  spuId: number
  spuName: string
  skuId: number
  skuName: string
  orderNum: number
  orderAmount: number
}

export type EnrollOrdersMonthStatsPageParam = PageParam &
  Partial<Pick<EnrollOrdersMonthStatsVO, 'orderNum'>>

export type SearchEnrollOrdersMonthStats = {
  month?: string
  nickname?: string
  mobile?: string
}

// 获取列表
export const getEnrollOrdersMonthStatsList = (data: EnrollOrdersMonthStatsPageParam) => {
  request.post<PageResult<EnrollOrdersMonthStatsVO[]>>({
    url: `${baseURL}/get-enroll-orders-month-stats`,
    data
  })
}

// 搜索报名订单月统计
export const searchEnrollOrdersMonthStats = (data: SearchEnrollOrdersMonthStats) => {
  request.post<PageResult<EnrollOrdersMonthStatsVO[]>>({
    url: `${baseURL}/search-enroll-orders-month-stats`,
    data
  })
}

// 课程订单日统计
export type CourseOrdersDayStatsVO = {
  id: number
  ststDate: string
  courseId: number
  courseName: string
  orderNum: number
  orderAmount: number
}

export type CourseOrdersDayStatsPageParam = PageParam &
  Partial<Pick<CourseOrdersDayStatsVO, 'orderNum'>>

export type SearchCourseOrdersDayStats = {
  day?: string
  nickname?: string
  mobile?: string
}
// 获取课程订单日统计列表
export const getCourseOrdersDayStatsList = (data: CourseOrdersDayStatsPageParam) => {
  request.post<PageResult<CourseOrdersDayStatsVO[]>>({
    url: `${baseURL}/get-course-orders-day-stats`,
    data
  })
}

// 搜索课程订单日统计
export const searchCourseOrdersDayStats = (data: SearchCourseOrdersDayStats) => {
  request.post<PageResult<CourseOrdersDayStatsVO[]>>({
    url: `${baseURL}/search-course-orders-day-stats`,
    data
  })
}

// 课程订单月统计

export type CourseOrdersMonthStatsVO = {
  id: number
  ststDate: string
  courseId: number
  courseName: string
  orderNum: number
  orderAmount: number
}

export type CourseOrdersMonthStatsPageParam = PageParam &
  Partial<Pick<CourseOrdersMonthStatsVO, 'orderNum'>>

export type SearchCourseOrdersMonthStats = {
  Month?: string
  nickname?: string
  mobile?: string
}
// 获取课程订单日统计列表
export const getCourseOrdersMonthStatsList = (data: CourseOrdersMonthStatsPageParam) => {
  request.post<PageResult<CourseOrdersMonthStatsVO[]>>({
    url: `${baseURL}/get-course-orders-month-stats`,
    data
  })
}

// 搜索课程订单日统计
export const searchCourseOrdersMonthStats = (data: SearchCourseOrdersMonthStats) => {
  request.post<PageResult<CourseOrdersMonthStatsVO[]>>({
    url: `${baseURL}/search-course-orders-month-stats`,
    data
  })
}
